using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class ReadCookiePage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if(Session["jsemail"]!=null)
        {
            Literal1.Text="You are logged as :<br>";
            Literal1.Text += "Email: " + Session["jsemail"].ToString();
            Literal1.Text += "<br>UserID: " + Session["jsid"].ToString();
        }
        
            
        if(Request.Cookies["Remember"]!=null)
        {
            HttpCookie httpCookie=
            Request.Cookies["EmailAndTime"];
            //GetValues(httpCookie);
            //GetValue(httpCookie);
            GetExpires(httpCookie);
        }
    }
    protected void LinkButton1_Click(object sender, EventArgs e)
    {      
        Session.RemoveAll();
        Session.Abandon();
        Response.Redirect("CreateHttpCookiePage.aspx");
    }

    void GetValues(HttpCookie httpCookie)
    {
        Literal2.Text =
        "Get Cookie name by Values Collection<br>";
        foreach (string value in httpCookie.Values)
        {
            Literal2.Text += value + "<br>";
        }
    }
    void GetExpires(HttpCookie httpCookie)
    {
        Literal2.Text =
        "Get Cookie Expire by Expires Collection<br>";
        DateTime dateTime = httpCookie.Expires;
         Literal2.Text += dateTime.ToShortDateString() + "<br>";
         
    }
    void GetValue(HttpCookie httpCookie)
    {
        Literal2.Text =
        "Get Cookie name by Value Collection<br>";
        if(httpCookie.HasKeys)
            Literal2.Text += httpCookie.Value + "<br>";
       
    }
}
